import Vue from 'vue'
import VueRouter from 'vue-router'

const Login = () => import('@/views/login')
const Register = () => import('@/views/register')
const Shop = ()=>import('@/views/shop/index.vue')

const Head = ()=>import('@/views/header/Headeruser.vue')

const ShopManage = () => import('@/views/shopmanage/index')

const ShopLive =() =>import('@/views/shoplive/index.vue')
const Aboutus =() =>import('@/views/aboutas/index.vue')
const Chatroom =() =>import('@/views/chatroom/index.vue')
const PersonalCenter =() =>import('@/views/personalcenter/index.vue')
const Shopdetail =() =>import('@/views/shopdetail/index.vue')

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/shop'
    },
    {
        path: '/shopdetail',
        component: Shopdetail

    },
    {
        path: '/login',
        component: Login,
    },
    {
        path: '/main',
        component: Head,
        children:[{
            path:'/shop',
            component:Shop,
            mate:{
                title:'商品主页'
            },
        },{
            path:'/shopmanage',
            component:ShopManage,
            mate:{
                title:'商品管理'
            },
        },{
            path:'/chatroom',
            component:Chatroom,
            mate:{
                title:'聊天室'
            },
        },{
            path:'/shoplive',
            component:ShopLive,
            mate:{
                title:'收藏的商品'
            },
        },{
            path:'/aboutus',
            component:Aboutus,
            mate:{
                title:'关于我们'
            },
        },{
            path:'/personalcenter',
            component:PersonalCenter,
            mate:{
                title:'个人中心'
            },
        },{
            path:'/shoplive',
            component:ShopLive,
            mate:{
                title:'收藏的商品'
            },
        },]
    },
    {
        path: '/register',
        component: Register,
    },
]

const router = new VueRouter({
    routes,
    // mode:"history",
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}
export default router
